package com.yang.leather.common.upload;

import java.util.ArrayList;
import java.util.List;

public class UploadRule implements java.io.Serializable{
	private static final long serialVersionUID = 1L;
	/**
	 * 在session中的key
	 */
	public static final String KEY = "_upload_rule";
	
	public static final String NO_RULE = "no_upload_rule";
	
	/**
	 * 已经上传的图片
	 */
	private List<UploadFile> uploadFiles;
	
	public List<UploadFile> getUploadFiles() {
		return uploadFiles;
	}

	public void setUploadFiles(List<UploadFile> uploadFiles) {
		this.uploadFiles = uploadFiles;
	}

	public void addUploadFile(String filePath,String fileName){
		if(uploadFiles == null){
			uploadFiles = new ArrayList<UploadFile>();
		}
		uploadFiles.add(new UploadFile(filePath,fileName));
	}
	
	
	public String getUploadRuleId(){
		return Long.toString(System.currentTimeMillis());
	}
	
	public static class UploadFile implements java.io.Serializable {

		private static final long serialVersionUID = 1L;
		
		private String filePath;
		private String fileName;
		
		public UploadFile(){}
		
		public UploadFile(String filePath,String fileName){
			this.filePath = filePath;
			this.fileName = fileName;
		}

		public String getFilePath() {
			return filePath;
		}

		public void setFilePath(String filePath) {
			this.filePath = filePath;
		}

		public String getFileName() {
			return fileName;
		}

		public void setFileName(String fileName) {
			this.fileName = fileName;
		}
		
	}

}
